package com.shop.controller;


import com.shop.dto.GoodsDto;
import com.shop.dto.GoodsDtoQuery;
import com.shop.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author wzby
 * @Date: 2022/10/21 10:13
 */
@RestController
@RequestMapping("/api/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;



    @GetMapping
    //查询所有
    public List<GoodsDto> selectXml(GoodsDtoQuery goodsDtoQuery){
       return goodsService.select(goodsDtoQuery);
    }





    @GetMapping("/{id}")
    public GoodsDto selectOne(@PathVariable Integer id){
        GoodsDtoQuery goodsDtoQuery = new GoodsDtoQuery();
        goodsDtoQuery.setId(id);
        return goodsService.select(goodsDtoQuery).get(0);
    }


}
